package com.liu.jdbc.myjdbc;

import org.junit.Test;

import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class JdbcConn {
    @Test
    public void connect() throws IOException, ClassNotFoundException, SQLException {
        Properties properties = new Properties();
        properties.load(new FileInputStream("src/mysql.properties"));
        String user = properties.getProperty("user");
        String password = properties.getProperty("password");
        String url = properties.getProperty("url");
        String driver = properties.getProperty("driver");
        Class.forName(driver);
        Connection connection = DriverManager.getConnection(url, user, password);
        String sql = "insert into  actor values (1,'小明'),(2,'小红'),(3,'小黄'),(4,'小蓝'),(5,'小绿')";
        //String sql = "update actor set orname = 'liu' where id = 1";
        //String sql = "delete  from actor where id = 3";
        Statement statement = connection.createStatement();
        int i = statement.executeUpdate(sql);
        System.out.println(i>0 ? "成功":"失败");

        statement.close();

    }
}
